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.
cancel
Showing results for 
Search instead for 
Did you mean: 

Populating internal table , column wise

Former Member
0 Kudos

Hi friends,

I have an important requirement regarding internal table population.

I have two internal tables. Both are being processed in a single loop.

ITAB1 has 1 field. ITAB2 has 5 fields.

ITAB1 ITAB2

-


-


Fld1 F1 F2 F3 F4 F5

1

2

3

4

5

let's assume that in the first loop iteration, ITAB1 has 5 records as shown above.

In the same loop pass I want to populate ITAB2 column wise. That is after the first loop pass ITAB2 should look like something below.

ITAB2

-


F1 F2 F3 F4 F5

1

2

3

4

5

In the second loop pass I want to populate ITAB2-F2 ONLY and i the third loop pass I want to populate ITAB2-F3 ONLY and so on.

Again assume that after the second loop pass ITAB1 has been populated again. And ITAB1 looks like

ITAB1

-


Fld1

11

22

33

44

55

So after the second loop pass ITAB2 should look like below.

ITAB2

-


F1 F2 F3 F4 F5

1 11

2 22

3 33

4 44

5 55

do 5 times.

Process ITB1..

Process ITB2..

enddo.

How can I go ahead with this development? Your helps will be highly appreciated with points.

1 REPLY 1

Former Member
0 Kudos

do 5 times.
var = sy-index.
Process ITB1..

Process ITB2..

enddo.

in the process itb2 do something like this.


loop at itab1.
case var.
when '1'.
move itab1-field to itab2-f1.
append itab2.
when '2'.
move itab1-field to itab2-f2.
modify itab2 index sy-tabix transporting f2.
when '3'.
move itab1-field to itab2-f3.
modify itab2 index sy-tabix transporting f3.
when '4'.
move itab1-field to itab2-f4.
modify itab2 index sy-tabix transporting f4.
when '5'.
move itab1-field to itab2-f5.
modify itab2 index sy-tabix transporting f5.
endcase.
endloop.

Hope it helps, didn't test it

Edited by: Ramiro Escamilla on Feb 7, 2008 9:07 PM

Minor changes, hope it helps