‎2009 Jun 09 9:22 PM
hi experts,
how can i do this.. i want to print the columns of a i-table as rows.. like inverting the table.. for example something like...
table1
col1 col2 col3
row1 1.00 2.00 3.00
row2 4.00 5.00 6.00
waht i want is to get this
row1 row2
col1 1.00 4.00
col2 2.00 5.00
col3 3.00 6.00
is there like a function ?? or someone had have done this???
thx in advanceee
‎2009 Jun 09 9:30 PM
Please search this forum with keyword "dynamic AND Internal AND table " you can find examples
a®
‎2009 Jun 09 10:51 PM
Hi,
You can try something like this.
Internal table itab_1 has 2 rows:
11 12
21 22
itab_2 will have inversed data as follows:
11 21
12 22
TYPES: BEGIN OF t_itab,
fld1 TYPE i,
fld2 TYPE i,
END OF t_itab.
DATA: itab_1 TYPE t_itab OCCURS 0 WITH HEADER LINE,
itab_2 TYPE t_itab OCCURS 0 WITH HEADER LINE.
DATA: v_counter TYPE i,
v_index LIKE sy-index.
FIELD-SYMBOLS: <fs1> TYPE ANY,
<fs2> TYPE ANY.
itab_1-fld1 = '11'.
itab_1-fld2 = '12'.
APPEND itab_1.
itab_1-fld1 = '21'.
itab_1-fld2 = '22'.
APPEND itab_1.
DESCRIBE TABLE itab_1 LINES v_counter.
DO v_counter TIMES.
v_index = sy-index.
LOOP AT itab_1.
CASE v_index.
WHEN '1'.
ASSIGN COMPONENT sy-tabix OF STRUCTURE itab_2 TO <fs1>.
MOVE itab_1-fld1 TO <fs1>.
WHEN '2'.
ASSIGN COMPONENT sy-tabix OF STRUCTURE itab_2 TO <fs2>.
MOVE itab_1-fld2 TO <fs2>.
ENDCASE.
ENDLOOP.
APPEND itab_2.
ENDDO.
Cheers,
Vikram
‎2009 Jun 10 12:21 AM
thx Vikram for the answer but.. my internal table have a column for each day of the month .. so i have like a 30 columns and like 20 rows ..
how can i take each column and append it to another table row??
thx in advance
‎2009 Jun 15 3:06 PM
well in case someone has the same problem, wat i did was a loop for the table as many columns it has, and passing the values with field symbols to the new table
do (columns)
loop table
endloop.
enddo.
greetings.