Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Transpose Internal table

Former Member
0 Kudos
2,329

Hi,

I want the logic how to transpose the internal table i.e colums to rows and rows to columns.

for example I have a internal table like



A B C D E F
a b c d  e f
1 2 3 4 5 6 


I want it as

A a 1
B b c
C c 3
D d 4
E e 5
F f 6

How to do the Same.

The problem is that I dont know until the run time the number of rows

I know its asked but I couldnt find them

Regards

Edited by: SAP LEARNER on Apr 20, 2009 2:43 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
605

Hi,

You need to use Field Symbols to achevie this...Refer to this link..http://docs.google.com/Doc?id=dfv2hmgs_5d6bcxqgp&hl=en

4 REPLIES 4
Read only

Former Member
0 Kudos
606

Hi,

You need to use Field Symbols to achevie this...Refer to this link..http://docs.google.com/Doc?id=dfv2hmgs_5d6bcxqgp&hl=en

Read only

Former Member
0 Kudos
605

As the number of fileds in the internal table is decided at runtime, its better to use Filed Group instead of Internal Table

Read only

0 Kudos
605

hi ,

You can try this code, Hope this helps you.

REPORT ZTRANSPOSE_PAV.

data : BEGIN OF itab OCCURS 0,

a(10) type c,

b(10) type c,

c(10) type c,

d(10) type c,

e(10) type c,

END OF itab.

itab-a = 'A'.

itab-b = 'B'.

itab-c = 'C'.

itab-d = 'D'.

itab-e = 'E'.

APPEND itab.

itab-a = 'a'.

itab-b = 'b'.

itab-c = 'c'.

itab-d = 'd'.

itab-e = 'e'.

APPEND itab.

itab-a = '1'.

itab-b = '2'.

itab-c = '3'.

itab-d = '4'.

itab-e = '5'.

APPEND itab.

LOOP AT itab. " Just for Displaying the Internal Table

WRITE 😕 itab-a,itab-b,itab-c,itab-d,itab-e.

ENDLOOP.

skip 5.

*********************Logic to Transpose Internal Table********************

loop at itab.

write itab-a.

ENDLOOP.

skip.

loop at itab.

write itab-b.

ENDLOOP.

skip.

loop at itab.

write itab-b.

ENDLOOP.

skip.

loop at itab.

write itab-d.

ENDLOOP.

skip.

loop at itab.

write itab-e.

ENDLOOP.

Read only

0 Kudos
605

HI... Its not for printing yar... I have to use the data again...

any way the Link solved my problem.....

Regards