Differences Between 2 Internal Tables

The class CL_ABAP_DIFF compares the content of 2 compatible internal tables and finds their differences.

The CREATE method returns the reference of the instance.

Then the method DIFF can be used to compare and find the difference between the source and the target internal tables.

A demo program to illustrate the use of the class. Here we have two simple integer tables.

Both tables are identical.

Make some changes to the table contents.

Here the tables are different. So the DIFF method returns the DIFF_RESULT which is a table that shows how the content of the table can be transformed into the content of the another table by DELETE/INSERT.

Also optionally the OUTPUT_MODE can be passed as UPDATE to the CREATE method, so that the DIFF method can help how the first table can be transformed to the second table by UPDATE.

Now the DIFF RESULT shows in terms of UPDATE operation.

The class has another method called: DIFF_WITH_LINE_REF which is an extension of the DIFF method with addition to the REFERENCE DATA to the line. Let’s use both the methods.

DIFF method- that just shows in terms of UPDATE operation.

DIFF_WITH_LINE_REF method- that just shows in terms of UPDATE operation and source & target line references..

It is also possible to compare a deep internal table also.

Output:


Leave a Reply