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

Make the column to row.(internal table)

Former Member
0 Likes
461

hi

i have an internal table ITAB

data:begin of itab 
        quarters(2),
       end of itab. 

that has contents

-


Q1

Q2

Q3

Q4

-


I would like to have a ITAB2 like this

data:begin of itab 
        Q1(2),
        Q2(2),
       Q3(2),
       Q4(2)
       end of itab. 

-


Q1 Q2 Q3 Q4 Q5

-


any ideas guys..........

thanks

raghu.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
396

*******************************************

REPORT z_test.

  • Transpose itab1 to itab2.

TYPES: BEGIN OF ty_1,

first,

second,

third,

fourth,

END OF ty_1.

TYPES: BEGIN OF ty_2,

first,

second,

third,

END OF ty_2.

FIELD-SYMBOLS: <fs> TYPE ANY,

<fs2> TYPE ANY.

DATA: itab1 TYPE TABLE OF ty_1 WITH HEADER LINE,

itab2 TYPE TABLE OF ty_1 WITH HEADER LINE,

curr_line TYPE sy-tabix.

itab1-first = '1'.

itab1-second = '2'.

itab1-third = '3'.

itab1-fourth = '4'.

APPEND itab1.

itab1-first = '1'.

itab1-second = '2'.

itab1-third = '3'.

itab1-fourth = '4'.

APPEND itab1.

itab1-first = '1'.

itab1-second = '2'.

itab1-third = '3'.

itab1-fourth = '4'.

APPEND itab1.

LOOP AT itab1.

CLEAR itab2.

ASSIGN COMPONENT sy-tabix OF STRUCTURE itab2 TO <fs>.

curr_line = sy-tabix.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE itab1 TO <fs2>.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF curr_line = 1.

<fs> = <fs2>.

APPEND itab2.

ELSE.

READ TABLE itab2 INDEX sy-index.

<fs> = <fs2>.

MODIFY itab2 INDEX sy-index.

ENDIF.

ENDDO.

ENDLOOP.

LOOP AT itab2.

WRITE:/ itab2.

ENDLOOP.

**************************************************

Please find the above code for the same.

Regards

Ramesh.

hi

i have an internal table ITAB

data:begin of itab 
        quarters(2),
       end of itab. 

that has contents

-


Q1

Q2

Q3

Q4

-


I would like to have a ITAB2 like this

data:begin of itab 
        Q1(2),
        Q2(2),
       Q3(2),
       Q4(2)
       end of itab. 

-


Q1 Q2 Q3 Q4 Q5

-


any ideas guys..........

thanks

raghu.

1 REPLY 1
Read only

Former Member
0 Likes
397

*******************************************

REPORT z_test.

  • Transpose itab1 to itab2.

TYPES: BEGIN OF ty_1,

first,

second,

third,

fourth,

END OF ty_1.

TYPES: BEGIN OF ty_2,

first,

second,

third,

END OF ty_2.

FIELD-SYMBOLS: <fs> TYPE ANY,

<fs2> TYPE ANY.

DATA: itab1 TYPE TABLE OF ty_1 WITH HEADER LINE,

itab2 TYPE TABLE OF ty_1 WITH HEADER LINE,

curr_line TYPE sy-tabix.

itab1-first = '1'.

itab1-second = '2'.

itab1-third = '3'.

itab1-fourth = '4'.

APPEND itab1.

itab1-first = '1'.

itab1-second = '2'.

itab1-third = '3'.

itab1-fourth = '4'.

APPEND itab1.

itab1-first = '1'.

itab1-second = '2'.

itab1-third = '3'.

itab1-fourth = '4'.

APPEND itab1.

LOOP AT itab1.

CLEAR itab2.

ASSIGN COMPONENT sy-tabix OF STRUCTURE itab2 TO <fs>.

curr_line = sy-tabix.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE itab1 TO <fs2>.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF curr_line = 1.

<fs> = <fs2>.

APPEND itab2.

ELSE.

READ TABLE itab2 INDEX sy-index.

<fs> = <fs2>.

MODIFY itab2 INDEX sy-index.

ENDIF.

ENDDO.

ENDLOOP.

LOOP AT itab2.

WRITE:/ itab2.

ENDLOOP.

**************************************************

Please find the above code for the same.

Regards

Ramesh.