cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing Table Content

Former Member
0 Kudos

Hi, I need to read two tables, and compare the field content in each. It's not just a case of checking how many lines are in each. Do I have to loop at each line then field, or does anyone know of a clever way of doing this ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jill Thompson

Can you elaborate on your question?

I mean the structure of 2 tables.

and

what exactly you want to do.

Like: Do you want to show a message of typemismatch if any of field mismatches or else?

Regards,

Vijay Raheja

Former Member
0 Kudos

I have to compare the values of the table in two different systems. If there any any differences I have to report them.

andreas_mann3
Active Contributor
0 Kudos

Hi,

for comparing in 2 sytems you can work with fm:

1) TABLE_ENTRIES_GET_VIA_RFC (with wheretab)

2) GET_TABLE_RFC for complete table

Andreas

Former Member
0 Kudos

by two different systems you mean different clients or different servers altogether...

if clients... u can use the "<b>client specified</b>" addition with the select and get data for two different clients...

for different servers (say DEV and QA) read the table in other system via RFC (as already suggested)

rgds,

PJ

Former Member
0 Kudos

Yes, I have managed to retrieve the tables. But do I have to loop thru' line by line to spot differences ?

Just comparing the tables only tells me if they have the same amount of columns and lines.

Former Member
0 Kudos

I think you have to loop through the first table and read the second one ...and compare the filed you want and move it to some another internal table for further processing.

Loop at tab1.

read tab2 with key fd1 = tab1-fd1.

if sy-subrc = 0.

*--move it some other internal tabe if needed

endif.

endloop.

You can improve the perfomance by sorting the tables and doing a binary serach in the read statemenmt

Former Member
0 Kudos

hi,

suppose you have itab1 and itab2

first compare like itab1[] = itab2[]

if sy-subrc is zero then there is no difference.

else if you want to find out particular line difference means you must go loop only

cheers,

sasi

Answers (2)

Answers (2)

andreas_mann3
Active Contributor
0 Kudos

Hi,

if you only want to know if there's a difference,

you can say :

if itab1[] = itab2[].

or by standard tables (without header line)

if itab1 = itab2.

regards Andreas

Former Member
0 Kudos

Hi,

loop at itab.

read table itab1 with key matnr = itab-matnr

.........

if itab-matnr ne itab1-matnr.

move .......to itab2.

endloop.

I hope it will be use full to u.

Thanks.