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

internal table

Former Member
0 Likes
498

How to fetch the data from 3 internal tables into another interna table?

5 REPLIES 5
Read only

Former Member
0 Likes
480

There will be atleast one key fields in 3 internal tables based on this you can write a logic.

eg:

loop at itab1.

move-corresponding itab1 to itfinal.

read table itab2 with key field1 = itab1-field1.

if sy-subrc = 0.

move-corresponding itab2 to itfinal.

endif.

read table itab3 with key field1 = itab1-field1.

if sy-subrc = 0.

move-corresponding itab3 to itfinal.

endif.

append itfinal.

clear itfinal.

endloop.

now the itfinal table contains the records from 3 tables.

Read only

Former Member
0 Likes
480

Hi Balu,

Suppose i have three internal tables ITAB1, ITAB2, ITAB3 into ITAB with a key field1.

do the following:-

loop at ITAB1.

clear ITAB.

move correspond ITAB1 to ITAB.

read table ITAB2 with key field1 = ITAB1-key.

move correspond ITAB2 to ITAB.

read table ITAB3 with key field1 = ITAB1-key.

move correspond ITAB3 to ITAB.

append ITAB.

endloop.

after this you will get all the data in ITAB internal table.

Or Else...

if there are common fields in the 3 internal tables , the use

sort itab1 by field1.

sort itab1 by field2.

sort itab1 by field3.

loop at itab1.

move-corresponding itab1 to it_final.

read table itab2 with key field1 = itab1-field1 binary search.

if sy-subrc eq 0.

move-corresponding itab2 to it_final.

endif.

read table itab3 with key field1 = itab1-field1 binary search.

if sy-subrc eq 0.

move-corresponding itab3 to it_final.

endif.

append it_final.

clear it_final.

endloop.

Regards,

Priyanka.

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
480

Hi

Use

ITAB 3 = itab1.

itab 3 = itab 2.

Regards,

kumar

Read only

Former Member
0 Likes
480

Hi,

You need to

Loop at ITAB1.

read ITAB2 with key <field2> = <itab1-field1>.

read ITAB2 with key <field3> = <itab1-field1>.

itab4-field1 = itab1-field1.

itab4-field2 = ita21-field2.

itab4-field3 = itab3-field3.

...

append itab4.

clear itab4.

endloop.

Internal table ITAB4 contains the combined data of all the three tables itab1,itab2,itab3.

Regards,

Saumya

Read only

Former Member
0 Likes
480

Hi,

1. Declare a final itab with all the fields and move the values of one db table to this

2. get the date from 2 tables

3. sort them

4. loop at final itab

5. read statement for each table and use binary search

6. modify final itab transporting the values

7.endloop.

Regards

Shiva