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: 

Compare 2 internal tables

Former Member
0 Kudos

Hi all,

I have 2 internal tables containing records from 2 different database tables.

How can i compare the 2 internal tables and produce result that the record exists in one table

but not in the second table.

Thanks,

/

Reddy.

1 ACCEPTED SOLUTION

rahulkavuri
Active Contributor
0 Kudos

loop at table1.
 
read table table2 where pmkey = pmkey2.
      
IF SY-SUBRC = 0.
 
delete table1.
 
ENDIF.
 
endloop.

The above code removes the data from new table...

6 REPLIES 6

Former Member
0 Kudos

same..

0 Kudos

HI Prabhakar,

do this way,

sort it_mseg2.

LOOP AT it_ekpo.

READ TABLE it_mseg2 binary search WITH KEY ebeln = it_ekpo-ebeln.

IF sy-subrc = 0.

it_ekpo1 = it_ekpo.

append it_ekpo1.

clear it_ekpo1.

ENDIF.

ENDLOOP.

Regards,

Santosh

rahulkavuri
Active Contributor
0 Kudos

loop at table1.
 
read table table2 where pmkey = pmkey2.
      
IF SY-SUBRC = 0.
 
delete table1.
 
ENDIF.
 
endloop.

The above code removes the data from new table...

Former Member
0 Kudos

Loop at one internal table1 .

Read theinternal table2 with some ctiteria to compare(Decide the deletion criteria based on some fields).

Then delete the rwo from internal table 2.

athavanraja
Active Contributor
0 Kudos

loop at table1 .

read table table2 with key ....

if sy-subrc eq 0 .

*record is there

else .

  • move the record to result tab .

endif .

endloop .

loop at table2 .

read table table1 with key ....

if sy-subrc eq 0 .

*record is there

else .

  • move the record to result tab .

endif .

endloop .

Regards

Raja

Former Member
0 Kudos
if there are comman fields in the 2 internal tables , 
add one more flag to itab2 of length 1

loop at itab1.

   read table itab2 with key keyfield1 = itab1-keyfield1 ....
       if sy-subrc = 0.
          itab2-flag = 'X'.
        modify itab2 transporting flag.
         endif.
endloop.

now depending on flag value u can distinguish them