2011 Sep 20 2:46 PM
Hi, people.
I have a request to develop a solution to read a matrix XY and apply a factor in the rows and columns.
I´d like to split the X axis in a internal table T1 and the Y axis in another internal table T2.
So I would have the same values in the tables, T1 in a vertical order and T2 in a horizontal order.
The idea is that when i change a value in one table T1, the same referenced value of T2 change dinamically.
I think that dynamic table could solve it but I don´t know how to build the code.
Appreciate if somebody could help me with examples to build the solution.
Thanks a lot.
Eduardo S.
2011 Sep 20 3:01 PM
I fail to see the benefit of your idea. Why would you hold redundant data?
A internal table with more than one record is a matrix, so why use two tables?
2011 Sep 20 3:24 PM
Hi, Florian. Thanks for your answer.
You are right. I have a matrix and that's the problem.
First I need to read the vertical lines of this matrix to find the total (of each vertical line).
This total will be used to calculate a factor that will be multiplied for all the cells (of each vertical line).
Then, after this, i will have new values in the matrix that should be seen horizontally.
The same process will occur with the horizontal lines.
I read the horizontal lines to find the total (of each horizontal line).
Then I calculate a factor that wil be multiplied for all the cells (of each horizontal line).
This process is called "balance" and will be used in a BPC solution.
That's why i thought in working with 2 linked internal tables.
Any suggestion ?
Thanks
Eduardo
2011 Sep 20 3:57 PM
Ok, got it, but still i dont see where the second table does more than make things complicated
So what you basically want is:
1. looping over the records, determining totals for each column.
2. derive some factor out of your total value, and multiply every field of this column with that factor.
3. determining a total for each row.
4. derive again soem factor out of that and multiply every field of the according row with that factor.
Did i get you right that you need the totals row-wise for the already columnwise adopted values?
to make things easier i´d add a field to your structure on that the itab is based on, that holds the total row-wise, and add a record at the end that holds the total columnwise.
solution should look something like:
data: itab type YOUR_TYPE,
wa like line of itab,
wa_total like line of itab.
loop at itab into wa.
wa_total-field1 = wa_total-field1 + wa-field1.
wa_total-field2 = wa_total-field2 + wa-field2.
...
"do that for all fields
endloop.
append wa_total to itab. "well not neccesary to append it
"in wa_total you got your totals column-wise, which leads to factors column-wise.
"now loop again
loop at itab into wa.
wa-field1 = wa-field1 * factor_column1.
wa-field2 = wa-field2 * factor_column2.
...
modify itab from wa index sy-tabix.
endloop.
now you got the vertikal things done. i guess based on this you should be able to come up with an idea how to do it for rows now.
2011 Sep 20 6:34 PM
Thanks for your example, Florian.
I will try to use your logic to develop a solution.
Soon I return with the news.
Eduardo
2011 Sep 21 4:48 AM
Hi,
I am littile bit confused and only understodd your problem partially. Could you please provide two records for example and explain it with your desired output required.
BR
Keshav