Row and Column transpose question

Dear Support ,
I would like to transpose one internal table , for example :
Column : MATERIAL , QTY , DATE
              MA1          ,  100  , 2009-01-01
              MA2          ,  200  , 2009-01-01
              MA3          ,  200  , 2009-03-02
After the convertion , it should be like that :
Column : MATERIAL , 2009-01-01 , 2009-03-02
              MA1            100                0
              MA2             200               0
              MA3             0                200
As i know , in SQL it is very easy to do that , just like :
select sum(case ' xxx ' when ' xxx ' .... ) ....
But how to do that in ABAP ?
Thanks .
Carlos Zhang

Hi,
Please find teh code as follows
TYPES : BEGIN OF t_itab,
         mat TYPE matnr,
         qty TYPE menge_d,
         dat TYPE datum,
        END OF t_itab.
TYPES : BEGIN OF t_datcol,
         dat TYPE datum,
         col TYPE i,
        END OF t_datcol.
DATA : tbl_obj  TYPE REF TO data,
       line_obj TYPE REF TO data.
DATA : lv_field TYPE fieldname.
DATA : wa     TYPE t_itab,
       wa_col TYPE t_datcol.
DATA: itab    TYPE STANDARD TABLE OF t_itab,
      itab_dt TYPE STANDARD TABLE OF t_datcol.
DATA : fcat TYPE lvc_t_fcat.
DATA : fcat_wa TYPE lvc_s_fcat.
DATA: cntr TYPE i.
FIELD-SYMBOLS : <fs>          TYPE t_datcol,
                <fs_mainitab> TYPE STANDARD TABLE,
                <fs_line>     TYPE ANY,
                <fs_field>    TYPE ANY.
wa-mat = 'M1'.
wa-qty = 100.
wa-dat = '20090101'.
APPEND wa TO itab.
wa_col-dat =  '20090101'.
APPEND wa_col TO itab_dt.
wa-mat = 'M2'.
wa-qty = 200.
wa-dat = '20090101'.
APPEND wa TO itab.
wa_col-dat =  '20090101'.
APPEND wa_col TO itab_dt.
wa-mat = 'M3'.
wa-qty = 200.
wa-dat = '20090302'.
APPEND wa TO itab.
wa_col-dat =  '20090302'.
APPEND wa_col TO itab_dt.
SORT itab_dt BY dat.
DELETE ADJACENT DUPLICATES FROM itab_dt COMPARING dat.
fcat_wa-fieldname = 'MAT'.
fcat_wa-ref_field = 'MATNR'.
fcat_wa-ref_table = 'MARA'.
APPEND fcat_wa TO fcat.
LOOP AT itab_dt assigning <fs>.
  <fs>-col = sy-tabix.
  CONCATENATE 'F_' <fs>-dat INTO lv_field.
  fcat_wa-fieldname = lv_field.
  fcat_wa-ref_field = 'MENGE'.
  fcat_wa-ref_table = 'MSEG'.
  APPEND fcat_wa TO fcat.
ENDLOOP.
now make your main internal table as required
dynamic table only incase if you do not know the dates
CALL METHOD cl_alv_table_create=>create_dynamic_table
  EXPORTING
    it_fieldcatalog           = fcat
  IMPORTING
    ep_table                  = tbl_obj
  EXCEPTIONS
    generate_subpool_dir_full = 1
    OTHERS                    = 2.
IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ASSIGN tbl_obj->* TO <fs_mainitab>.
CREATE DATA line_obj LIKE LINE OF <fs_mainitab>.
ASSIGN line_obj->* TO  <fs_line> .
IF <fs_mainitab> IS ASSIGNED AND <fs_line> IS ASSIGNED.
  LOOP AT  itab INTO wa.
    ASSIGN COMPONENT 'MAT' OF STRUCTURE <fs_line> TO <fs_field>.
    IF <fs_field> IS ASSIGNED.
      <fs_field> = wa-mat.
      UNASSIGN <fs_field> .
      READ TABLE itab_dt INTO wa_col
      WITH KEY dat = wa-dat.
      IF sy-subrc EQ 0.
        cntr = wa_col-col + 1.
        ASSIGN COMPONENT cntr OF STRUCTURE <fs_line> TO <fs_field>.
        IF <fs_field> IS ASSIGNED.
          <fs_field> = wa-qty.
          COLLECT <fs_line> INTO <fs_mainitab>.
          UNASSIGN <fs_field> .
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.
Regards,
Ankur Parab
Edited by: Ankur Parab on Jun 24, 2009 4:04 PM

Similar Messages

  • Rows to columns/Transpose the records Query and Display output

    hi ,
    can anyone help me query this and transpose it to this format?
    i am still a beginner in sql.
    thanks for help!
    Rows to columns/Transpose the records Query and Display output
    id     startdate     endate                    
    1111     1/2/2001     11/3/2001                    
    1111     2/5/2002     4/3/2002                    
    1111     2/6/2000     2/5/2001                    
    3333     5/2/2003     11/3/2003                    
    3333     6/2/2003     12/3/2003                    
    3333     2/6/2005     2/5/2005                    
    desired output     
    id     startdate1     endate1     startdate2     endate2     startdate3     endate3
    1111     1/2/2001     11/3/2001     2/5/2002     4/3/2002     2/6/2000     2/5/2001
    3333     5/2/2003     11/3/2003     6/2/2003     12/3/2003     2/6/2005     2/5/2005

    Have you only 3 dates for each id ?
    So, try :
    SQL> l
      1  with tbl as
      2  (select 1111 as id, to_date('01/02/2001','DD/MM/YYYY') startdate, to_date('11/03/2001','DD/MM/YYYY') enddate from dual union all
      3  select 1111 as id, to_date('02/05/2002','DD/MM/YYYY') startdate, to_date('04/03/2002','DD/MM/YYYY') enddate from dual union all
      4  select 1111 as id, to_date('02/06/2000','DD/MM/YYYY') startdate, to_date('02/05/2001','DD/MM/YYYY') enddate from dual union all
      5  select 3333 as id, to_date('05/02/2003','DD/MM/YYYY') startdate, to_date('11/03/2003','DD/MM/YYYY') enddate from dual union all
      6  select 3333 as id, to_date('06/02/2003','DD/MM/YYYY') startdate, to_date('12/03/2003','DD/MM/YYYY') enddate from dual union all
      7  select 3333 as id, to_date('02/06/2005','DD/MM/YYYY') startdate, to_date('02/05/2005','DD/MM/YYYY') enddate from dual )
      8  select id, max(decode(dr,1,startdate)) start1,
      9             max(decode(dr,1,enddate)) end1,
    10             max(decode(dr,2,startdate)) start2,
    11             max(decode(dr,2,enddate)) end2,
    12             max(decode(dr,3,startdate)) start3,
    13             max(decode(dr,3,enddate)) end3
    14  from (select id, startdate,enddate, dense_rank() over (partition by id order by startdate) dr from tbl)
    15* group by id
    SQL> /
                                                    ID START1   END1     START2   END2     START3   END3
                                                  1111 02/06/00 02/05/01 01/02/01 11/03/01 02/05/02 04/03/02
                                                  3333 05/02/03 11/03/03 06/02/03 12/03/03 02/06/05 02/05/05
    SQL> HTH,
    Nicolas.

  • Is it possible to switch the rows and columns?

    Is it possible to switch the rows and columns of a table? The reason I ask is that it would be easier for me to input the data with the number at the top of a column and the fields going down. But it would be easier to read the data with the number on the left and the fields going to the right. Is it possible to switch a table in this way?

    mahongue wrote:
    Is it possible to switch the rows and columns of a table? The reason I ask is
    that it would be easier for me to input the data with the number at the top
    of a column and the fields going down. But it would be easier to read the
    data with the number on the left and the fields going to the right. Is it
    possible to switch a table in this way?
    It sounds to me as though you wish to transpose a table so that the original is changed from rows to columns and from columns to rows, as in the following:
    Table 1
        A   B   C
    ========
    1   o   p   q
    2   r   s   t
    3   u   v   w
    Table 2
        A   B   C
    ========
    1   o   r   u
    2   p   s   v
    3   q   t   w
    You are right - it would be nice to have a menu item to magically transpose a selected block of cells. But there isn't one. So...
    One way to solve this is to use the index() and transpose() functions to accomplish row and column cell transposition. If you are going to use a 1:1 cell correspondence and change the header columns and rows also, you can use this:
       =INDEX(TRANSPOSE(Table # :: <range>),ROW(),COLUMN())
    where Table # and <range> is substituted as in the following fashion:
       =INDEX(TRANSPOSE(Table 1 :: $A$1:$C$3),ROW(),COLUMN())
    Create a second table. Copy the modified formula above with the appropriate substitutions, select the range you wish to have your transposition inserted into (must match the transposed cell dimensions of the original range), paste the forumula and voila! the cells will be transposed.
    Cautions:
    o The target table must match the swapped cell length and width dimension. For example, if the original data range is 6 columns wide by 4 rows deep, then the corresponding table or range to hold the transposition must be 4 columns wide by 6 rows deep.
    o If your transposed data block is to be offset from the origin of the new table, then you will need to include a subtractive offset into your cell formula, since in the transpose() function the data in the master data range is referenced from its position with the master range, not its cell position in the table. Such an offset is necessary because this example formula uses the target row and column numbers to arrive at indexed positions.
    For example, if the new data range is to be offset one column to the right and one row below from the target table's origin then you must subtract (-1) from the cell and from the column references in the formula:
      Example:
      =INDEX(TRANSPOSE(Table 3 :: $B$2:$D$4),ROW()-1,COLUMN()-1)
    If someone has a better solution I'd be glad to hear of it.

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

  • Table name input. and output i need  all rows and columns  using procedures

    hi,
    question: table name input. and output i need all rows and columns by using procedures.
    thanks,
    To All

    An example of using DBMS_SQL package to execute dynamic SQL (in this case to generate CSV data in a file)...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • Report with multiple dimensions in Row and Column with EvEXP

    Hi
    We are currently running BPC 7.0 SP3 and try to create the report(or schedule) with more 2 x 2 dimensions in the row and column.
    e.g.
    row dimension : Outer row is Entity, Inner row is Account
    column dimension : Outer column is Time, Inner row is Category
    We created the report with  2 x 2 dimensions like above e.g. with EvEXP and EvNXP, NOT EvDRE
    based on default dynamic template:Template13.xlt(Nested Row, 2 x 1 dimensions defined by EvEXP and EvNXP formula).
    However, when expanding the dimension with double click these dimensions or change CV of the report with  2 x 2 dimensions defined by EvEXP and EvNXP formula,
    error occurs on EvEXP and EvNXP formula and can't retrieve the result correctly.
    [Question]
    Can't we create the report with more 2 x 2 dimensions in the row and column using EvEXP and EvNXP function ?
    We understand that we can make the report with more 2 x 2 dimensions in the row and column if using EvDRE.
    Thank You in advance
    Kenya

    Thank you for your advice.
    I understand that we should use EvDRE when creating the report with multiple dimension in the row/column because EvEXP have some erros, poor performance, etc.
    Then, we have two questions.
    1)
    >plus they had some errors in the designs.
    what kind of errors they have as an example?
    2)
    >If you must build the EVEXP and EVNXP, I would suggest building the template from scratch
    We built the simple template with just 2 x 2 dimension from scratch.
    But this report doesn't work well when double-click the dimension or changing CV...
    Would you please check the following template?
    <https://sapmats-de.sap-ag.de/download/download.cgi?id=RCZE1ME4YSORY3DCDO4NNMANZLBL1L5ZBUOB2F71YVNVS8XDJW>
    It would be greatly appreciated if you could give me your advice for the template.
    Thank you again
    And my best regards,
    Kenya

  • How can I preserve row and column addresses on multiple cells at once in Numbers?

    How can I preserve row and column addresses on multiple cells at once in Numbers 3.2.2? I do a lot of rearranging and sorting and want to reference cells in other sheets. After entering the formulas (example: '=Sheet1::Table 1::H126') I will sort the table and the formulas will not move with the sort.  I think I can fix this by going cell by cell checking the 'preserve row' and 'preserve column' boxes when editing the formula.  I want to avoid having to go one by one.  I know that checking the boxes creates a formula like this: '=Sheet1::Table 1::$H$126'  I have also tried entering this manually and filling down but it doesn't include the preservations (the $$) in the autofill.  If there is another way to remedy my sorting problem that would also be welcomed!
    THANKS!!

    The title of the post is this
    How can I preserve row and column addresses on multiple cells at once in Numbers?
    I restated the Question as follows
    Can "Preserve Row" an / or "Preserve Column" be set on multiple cells at the same time.
    In both cases it is not asked if multiple cells can be set to....
    That is a given.
    Step back a second...  It is like selecting multiple cells and setting the text color of the currently selected cells to red. This can be done. More than one cell at a time modified because they are currently selected.
    Whats is being asked is:  if more than one cell is selected at the same time can the settings "Preserve Row" an / or "Preserve Column" be applied. No table I put up will help with that question.
    YES or NO
    If YES how?

  • Arrays[][] - row and column

    Evening All...
    Just a quick question regarding arrays. My program is working but I am trying to tidy it up.
    public class Arrays{
    static int firstArray[][]= new int [][] {{8,5},{9,3}};
    static int secondArray[][]= new int [][] {{1,7},{4,8}};
    static int thirdArray[][]= new int [][] {{0,2,4},{9,6,8}};
         static int fourthArray[][]= new int [][] {{2,1,0},{6,2,3}};
    public static void main(String[] args)
         multiply(secondArray,firstArray);
         multiply(firstArray,thirdArray);
         public static void multiply( int[][] x, int[][] z)
         int array2[][] = new int [3][3];
         int 1r = x.length;
         int 1c = x[0].length;
         int 2r = z.length;
         int 2c = z[0].length;
         //for(etc...)
    //      (Rest of program)
    I want to edit the array.--------int array2[] = new int[3][3]; (up 9 lines)
    Instead of specifying it as [3][3] for size.
    I would like to say new int - length of row and column - im pretty sure it is similar to
    the ints below - but cant seem to get the correct combination.
    Thanks in advance for any help folks.

    - you can use variables to specify array dimensions
    - you can get the (1D) dimension of an array by using the "attribute" theArray.length . Knowing that a 2D-array is indeed an array of arrays, you can indirectky get the size oif the second dimension too:
    public static void multiply( int[][] x, int[][] z) 
    int array2[][] = new int [x.length][x[0].length];                  
    }Of course this shoud be robustified to protect against x or x[0] being null (but in this case the multiplication is probably doomed anyway).
    Regards,
    J
    Edited by: jduprez on Mar 14, 2011 10:45 PM
    And please, in the future, use tags around code text, when posting code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Formulas results outside of row and column axis

    The report has an area of row axis and column axis. This area is where the results from BW are displayed.
    We have a requirement where we would have to create formulas using the BW Analyzer results of the row axis and column axis and display the results after the last row of this area.
    For example, after the BW Analyzer displays the result area to the Excel, we are required to take Excel Cell D10 * C7 and put the results to B33.
    <b>B33 = D10*C11</b>
    Excel row 30 is the last row from the row axis result area.
    I have searched through the forum for Cell Editor, but it seems that the requirement is to use 2 structures and use Cell Editor only when there is a formula collision. Our requirement has 1 structure, but I guess we can create the other structure for the column axis results. But still I think Cell Editor is a computation of formula collision within the row and column axis result area.
    My question is will Cell Editor meet our requirement if we want to get formula results from the row and column axis and then display the results outside of the row and column axis result area?
    Our approach was to use the Excel cell formulas in the workbook or possibly macros, but it seems that the Excel formulas will do.
    Would someone clarify about the Cell editor for this requirement and how would you approach this?
    Would this be effective to do the formulas from the query level? We are working on 3.5 SP11.

    Can Cell editor do the following:
    1. Create structures
    2. Run the query
    3. The results of the structures are displayed in the row and column axis of the BEx Analyzer
    4. Save as a workbook
    5. Use the Cell Editor to pick and choose the cells (Not the Excel cells) to create formulas
    6. The formula results are then displayed outside of the row and column axis.
    Would this be another approach?
    What scenario can Cell editor be used? What scenario can Cell editor not be used?
    Thanks

  • Select row and column from header in jtable

    hello i have a problem to select row and column from header in jtable..
    can somebody give me an idea on how to write the program on it.

    Hi Vicky Liu,
    Thank you for your reply. I'm sorry for not clear question.
    Answer for your question:
    1. First value of Open is item fiels in Dataset2 and this value only for first month (january). But for other month Open value get from Close in previous month.
    * I have 2 Dataset , Dataset1 is all data for show in my report. Dataset2 is only first Open for first month
    2. the picture for detail of my report
    Detail for Red number:
    1. tb_Open -> tb_Close in previous month but first month from item field in Dataset2
    espression =FormatNumber(Code.GetOpening(Fields!month.Value,First(Fields!open.Value, "Dataset2")))
    2. tb_TOTAL1 group on item_part = 1
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)))
    3. tb_TOTAL2 group on item_part = 3 or item_part = 4
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) + ReportItems!tb_TOTAL1.Value )
    4. tb_TOTAL3 group on item_part = 2
    expression =FormatNumber(Sum(CDbl(Fields!budget.Value)) - ReportItems!tb_TOTAL2 .Value)
    5. tb_Close -> calculate from tb_TOTAL3 - tb_Open
    expression =FormatNumber(Code.GetClosing(ReportItems!tb_TOTAL3.Value,ReportItems!tb_Open.Value))
    I want to calculate the value of tb_Open and tb_Close. I try to use custom code for calculate them. tb_close is correct but tb_Open is not correct that show value = 0 .
    My custom code:
    Dim Shared prev_close As Double
    Dim Shared now_close As Double
    Dim Shared now_open As Double
    Public Function GetClosing(TOTAL3 as Double,NowOpening as Double)
        now_close = TOTAL3 + NowOpening
        prev_close = now_close
        Return now_close
    End Function
    Public Function GetOpening(Month as String,NowOpen as Double)
        If Month = "1" Then
            now_open = NowOpen
        Else    
            now_open = prev_close
        End If
        Return now_open
    End Function
    Thanks alot for your help!
    Regards
    Panda A

  • Table -- sum of rows and columns?

    I was wondering if anyone has a suggestion to how I can easily generate the sum of each row and column in a two dimensional table? This is what I've got so far:
    public class SumRowsColumns {
        public static void main (String[] args) {
         int[][] table = new int[2][3];
         // gets the values
         for (int i = 0; i < table.length;
              i++) {
             for (int j = 0; j < table.length;
              j++)
              table[i][j] = Terminal.lesInt(); // Terminal is a class that can read the terminal input
         System.out.println("\t\t\t\tSum:");
         // prints the values
         for (int i = 0; i < table.length;
         i++) {
         for (int j = 0; j < table[i].length;
              j++) {
              System.out.print("\t" + table[i][j]);
         System.out.println();
         // sum of first column
         int sumColumn = 0;
         for (int i = 0; i < table.length;
         i++) {
              sumColumn += table[i][0];
         System.out.print("\nSum:\t");
         System.out.println(sumColumn);
    Example of output:
    1
    2
    3
    4
    5
    6
                                    Sum:
            1       2       3
            4       5       6
    Sum:    5This is the output I'd like:
    1
    2
    3
    4
    5
    6
                                    Sum:
            1       2       3     6
            4       5       6     15
    Sum:    5     7     9One way of getting the sum for all the columns is to make a for-loop for each one of them, but there has to be a better way. I could apply the same hack to get the sum of the rows, but I still wouldn't know how to get the layout I want.

    After many hours of frustration I finally solved it (for-loops can be confusing, man) after I got a hint from a post in another forum: http://www.linuxquestions.org/questions/showthread.php?postid=624021#post624021
    A more logical name to the integers actually helped a lot too. And here's the final product:
    public class SumRowsColumns {
        public static void main (String[] args) {
         int[][] table = new int[2][3];
         // gets the values
         for (int row = 0; row < table.length;
              row++) {
             for (int col = 0; col < table[row].length;
               col++)
              table[row][col] = Terminal.lesInt(); // Terminal is a class that reads the terminal input
         System.out.println("\t\t\t\tSum:");
         // prints the values and sum of each row
         for (int row = 0; row < table.length;
              row++) {
             for (int col = 0; col < table[row].length;
               col++) {
              System.out.print("\t" + table[row][col]);
             int sum = 0;
             for (int col = 0; col < table[0].length;
               col++) {
              sum += table[row][col];
             System.out.println("\t" + sum);
         System.out.print("\nSum:");
         // sum of each column
         for (int col = 0; col < table[0].length; // table[0].length is the length of row 0 (the number of columns)
              col++) {
             int sum = 0;
             for (int row = 0; row < table.length; // table.length is the number of rows
               row++) {
              sum += table[row][col];
             System.out.print("\t" + sum);
         System.out.println();
    }

  • Sum calculated rows and columns

    I have written a SQL report to count the number of offenses by levels of disciplinary actions.  Now I want to total
    the counts for the rows and columns.  How do I do this? Below is my code.  It produces column headings with counts.  Ie.
    Offense Description   Level I  Level II  Susps Terms
    2 Minor Violations      0         1       
    0    0  
    SELECT
    UPPER(DESCRIPTION) as OFFENSE,
    SUM(CASE
    WHEN OUTCOME = 'LEVEL I'
    THEN 1
    ELSE 0
    END) as LEVELI,
    SUM(CASE
    WHEN OUTCOME = 'LEVEL II'
    THEN 1
    ELSE 0
    END) as LEVELII,
    SUM(CASE
    WHEN OUTCOME = 'SUSPEND'
    THEN 1
    ELSE 0
    END) as SUSPEND,
    SUM(CASE
    WHEN OUTCOME = 'TERM'
    THEN 1
    ELSE 0
    END) as TERM
    FROM
    PAGRDI
    Where
    R_DATE >= '2014-01-01' and R_DATE <= '2014-01-31'
    Group by
    DESCRIPTION
    Order by
    OFFENSE

    Hi Wildcatgirl,
    According to your description, you have used T-SQL to get the counts for different OUTCOME. Now you want to get the total for each OFFENSE and OUTCOME. Right?
    In this scenario, since you have already get those counts with T-SQL query, so in your dataset it will have data fields below: OFFENSE, LevelI, LevelII, SUSPEND, TERM. We just need to drag these data fields into a table, add a column at the end of the table
    and use expression to sum the counts for different OUTCOME. Then we can add a total for the detail row. We have tested this scenario in our local environment. Here are screenshots for your reference:
    Reference:
    Tables (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Maximum number of rows and columns in data form

    Hi,
    I wanted to know if there is a limitation to the number of rows and columns that can be displayed in a data form, in Hyperion planning 11.1.2.1 ?
    And what would be the most appropriate number of rows and columns to be included for optimum performance.
    Thanks.

    Hi,
    While its a fun fact to determine how much one can stuff into a web form, the reality is: how much can a user reasonably consume in a web form?
    And what would be the most appropriate number of rows and columns to be included for optimum performance
    You will find that the answer to this is by "what design makes a web form most usable?" And no, the users don't really know what they want from a design perspective, they see it in their head, but usually what they ask for is something that would look entirely different (huge).
    The next thing to think about is the use of member selection functions in the page axis. IDescendants(Entity) in a dropdown could cause issues just as easily as too many rows - and again make the drop down unusable for a user.
    If your question is a bit more technical, then consider this (somewhat oversimplified): Web forms are constructed by a process on the server. Objects are created based on the form's definition and used by the process that builds the form. The process uses Cartesian looping (lots of iterations) to construct the form cell by cell, starting at the top left and finishing up in the bottom right. If the form has a million cells on it, then the loop and all the code within it runs a million times. The capability of the server has a lot to do with how well it can handle this request, and how many it can handle at one time.
    The result of this is gobs of HTML and JavaScript. All of this has to be sent over a network to the requesting client. The client starts receiving the web page code and has to render it in the browser and run the JavaScript. The ability to do this is limited by the browser, the OS, and the hardware that the client is running on.
    And that's just rendering the page for use.
    Now it has to be interacted with on the client machine, and changes parsed, packaged, and sent back to the server.
    So the technical answer is, there can be many limitations to how many rows and columns a data form can have - none of which can truly be anticipated by anyone. This is why I put the part about usability first in this post.
    Regards,
    Robb Salzmann

  • JTable  - Rows and columns

    I have created a JTable that displays the results from a query. My question is how can I get the JTable to display only a given number of rows and columns and have a scrollbar to see the rest of the cells?
    Thank you

    an easy way would be to use setSize()

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

Maybe you are looking for

  • My Exchange Calendar shows an "Exclamation Error" but there is no detail when I click it.

    OSX 10.8.2 Added an Exchange Account through the wizard, Calendar worked for a number of months but stopped some time recently.  Perhaps when I did a password change.  Perhaps when I upgraded to Outlook 2013 on my work PC Updated my password, Mail wo

  • DMS Tab it's not visible in Project Management (PPM 5.0)

    Hello Gurus; I have been active the SAP DMS option in: SPRO --> SAP Portfolio and Project Management --> Project Management --> Structure --> Define Project Types And configured the document settings: SPRO --> SAP Portfolio and Project Management -->

  • 8D report in Different Language

    Dear All we are using the 8D report in Quality notification for Vendor related complaint . Some of users are printing the same in English language and few other need to print this in other language . how we can proceed for this situation? Pl guide

  • Adding text string to existing cell contents in Numbers '09

    Hi First up ... I have read the manual (user guide and formula guide) and searched the forum. I have REALLY tried to get this simple thing to work... but I'm doing something wrong... 2 columns A B file1 .aiff File2 .aiff file3 .aiff file4 .aiff I wan

  • FIN-FSCM-LP (Plug-in in migration to 6.0)

    We are migrating from release 4.7 to 6.0. In addition we are creating for the new release a new company which is going to use liquidity planner (only liquidity calculation). We are already using Liquidity Planner (only liquidity calculation) for the