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

How to convert each row of internal table into column

0 Kudos

Hello Gurus,

Can you please explain the way or approach to implement report for below output. itab[] entries may increase.

Thank you.


Active Participant
0 Kudos


You can create a Dynamic table from your field catalog and fill it with field symbols.


Active Contributor
0 Kudos

Sorry but you can't have an internal table with 2 same field names e.g. FIELD1 can appear only once.

Active Participant
0 Kudos


If I understood correctly, my procedure would be:

1. Find the maximum number of rows with the same DOCNUM.

2. Multiply this number by the number of FIELD columns.

3. Add 1 to the calculated number. This is the component count of the OUTPUT table.

- Formula: 1 + ( [Number of FIELD columns] x [Maximum number of rows with same DOCNUM] )

- In your example this number would be: 1 + ( 4 x 4 ) = 17

4. Create a dynamic structure with the first field being DOCNUM followed by the FIELD fields.

- First field: DOCNUM (1x)

- Subsequent fields: Repetitive of FIELD fields (in your example 4 x 4 = 16x). Add a counter to FIELD columns to make them unique.

5. Create a dynamic table from the dynamic structure.

6. Sort the ITAB table by DOCNUM.

7. Loop at the ITAB table group by DOCNUM.

8. Add an initial line to OUTPUT table and assign it to a field symbol. Let's say this is <dst>. (dst: destination)

9. For each new group, set the DOCNUM field in the <dst> structure.

10. For each row that have same DOCNUM group, move the FIELD fields to the corresponding fields in <dst>. While doing this, a COUNTER variable can be used. (When the COUNTER value reaches the total number of FIELD columns per DOCNUM, transfer was done).

11. Eventually, the OUTPUT table will have rows where some FIELD fields are full and some are empty based on the number of rows in each DOCNUM.