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

combining internal tables

Former Member
0 Likes
717

hi!

If I have 3 internal tables it,it1and it2. it contains 5 colums out of which one is filled. The next 2 columns are to be filled from the 2 columns from it1 and the next 2 with the 2 columns from it2. how can do this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
692

Hi,

Then how do you update internal table IT from the other internal tables IT1 and IT2..

Otherwise..Give us a sample data for IT, IT1 and IT3...What is the output you want???That might give us some idea about your requirement...

Thanks,

Naren

6 REPLIES 6
Read only

Former Member
0 Likes
692

Hi,

Assuming the column that is filled is the common field for all the three internal tables..I am assuming the column name as FILLED_ONE.

LOOP AT IT.

READ TABLE IT1 WITH KEY FILLED_ONE = IT-FILLED_ONE.

IF SY-SUBRC = 0.

  • MOVE THE SECOND AND THRID COLUMNS FROM IT1.

IT-SECOND = IT1-XXX.

IT-THIRD = IT1-XXX.

ENDIF.

READ TABLE IT2 WITH KEY FILLED_ONE = IT-FILLED_ONE.

IF SY-SUBRC = 0.

  • MOVE THE FOURTH AND FIFTH COLUMNS FROM IT2.

IT-SECOND = IT2-XXX.

IT-THIRD = IT2-XXX.

ENDIF.

  • UPDATE THE INTERNAL TABLE IT.

MODIFY IT.

ENDLOOP.

Thanks,

Naren

Read only

0 Likes
692

thx Naren!

but what if all the three internal tables does'nt have a common column?

cheers.

Read only

Former Member
0 Likes
693

Hi,

Then how do you update internal table IT from the other internal tables IT1 and IT2..

Otherwise..Give us a sample data for IT, IT1 and IT3...What is the output you want???That might give us some idea about your requirement...

Thanks,

Naren

Read only

0 Likes
692

thx Naren!

let us assume that:

it1 contains matnr;

it2 contains labst,insme,speme;

I want to put all these fields in it3.

Read only

0 Likes
692

Hi,

But it1 & it2 should have atleast one common fields so that you read the correct entry & put it into it3.

Because..it1 & it2 may have more than 1 entry so how do we know which row of it1 & which row of it2 should be copied into it3?

Raja T

Read only

raja_thangamani
Active Contributor
0 Likes
692

Hi,

Create the Final_itab which will have all column which you need from other 3 Itab..


loop at itab1.
 
   read table itab2 with key field1 = itab1-field1 
                             field2 = itab1-field2. 
 
   read table itab3 with key field1 = itab1-field1 
                             field3 = itab1-field3. 
 
   move-sorresponding itab1 to it_final.
   move-sorresponding itab2 to it_final.
   move-sorresponding itab3 to it_final.
   append it_final.
   clear it_final.   
endloop.

check these thread...

Raja T

Message was edited by:

Raja T