F Differences between two internal tables using CL_ABAP_DIFF | CodeTheta

Differences between two internal tables using CL_ABAP_DIFF

June 22, 2026

Code :
REPORT zvp_cl_abap_diff.
TYPES: BEGIN OF ty_str,
         id   TYPE int4,
         name TYPE char10,
       END OF ty_str.

DATA: it_a TYPE STANDARD TABLE OF ty_str,
             it_b TYPE STANDARD TABLE OF ty_str.

it_a = VALUE #( ( id = '1' name = 'AAA' )
                             ( id = '2' name = 'BBB' ) ).

it_b = VALUE #( ( id = '1' name = 'AAA' )
                             ( id = '2' name = 'ABC' ) ).

TRY.
    DATA(lo_diff) = cl_abap_diff=>create( ).
    lo_diff->diff(
      EXPORTING
        target         = it_a
        source       = it_b
      IMPORTING
        flag_identical = DATA(lv_identical)
      RECEIVING
        diff_result    = DATA(it_diff) ).
    IF lv_identical = abap_false.
      write:/ 'Not Identical'.
    ELSEif lv_identical = abap_true.
      write:/ 'Identical'.
    ENDIF.
  CATCH cx_abap_diff.
ENDTRY.

Output :
Not Identical

Try this code in your system for better understanding. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Post a Comment