Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to retrieve internaltable column wise data in rowwise

hi all,

My question is Suppose I have intenal table with 3 cols and 4 rows of data.Now i want to display table first col data as first row and so on...

input data :

eg: c1 c2 c3

r1 1 2 3

r2 4 5 6

r3 7 8 9

r4 10 11 12.

outputdata should be like this:

1 4 7 10

2 5 8 11

3 6 9 12.

please help me out ,

Thanks in advance,

Santhosh.E

Tags:
replied

Hi,

It can be done easily in a single loop.

Try this code.

DATA: BEGIN OF itab OCCURS 0,
        f1 TYPE i,
        f2 TYPE i,
        f3 TYPE i,
      END OF itab.
DATA pos TYPE i.

"Define your lines where you want to print here...
<b>DATA line1 TYPE i VALUE 10.
DATA line2 TYPE i VALUE 12.
DATA line3 TYPE i VALUE 14.</b>

itab-f1 = '1'.
itab-f2 = '10'.
itab-f3 = '100'.
APPEND itab.

itab-f1 = '2'.
itab-f2 = '20'.
itab-f3 = '200'.
APPEND itab.

itab-f1 = '3'.
itab-f2 = '30'.
itab-f3 = '300'.
APPEND itab.

itab-f1 = '4'.
itab-f2 = '40'.
itab-f3 = '400'.
APPEND itab.

LOOP AT itab.
  pos = pos + 10.

<b>  SKIP TO LINE line1.
  POSITION pos.</b>
  WRITE itab-f1.

<b>  SKIP TO LINE line2.
  POSITION pos.</b>
  WRITE itab-f2.

<b>  SKIP TO LINE line3.
  POSITION pos.</b>
  WRITE itab-f3.
ENDLOOP.

Ps: Reward points if helpful.

Regards,

Wenceslaus.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question