compare the difference between tab1 and tab2. The results are the lines which are tab1 is difference from tab2.
REPORT zdiffer_tab.
TYPES: BEGIN OF ty_tab,
name(10) TYPE c,
sex(1) TYPE c,
tel(11) TYPE c,
END OF ty_tab.
DATA: lt_tab1 TYPE STANDARD TABLE OF ty_tab,
lt_tab2 TYPE STANDARD TABLE OF ty_tab.
DATA: lw_tab TYPE ty_tab,
g_nochange TYPE c,
lt_res TYPE STANDARD TABLE OF ty_tab.
lw_tab-name = 'Tom'.
lw_tab-sex = 'Y'.
APPEND lw_tab TO lt_tab1.
lw_tab-name = 'Lucy'.
lw_tab-sex = 'X'.
APPEND lw_tab TO lt_tab1.
lw_tab-name = 'Jerry'.
lw_tab-sex = 'Y'.
APPEND lw_tab TO lt_tab2.
lw_tab-name = 'Lucy'.
lw_tab-sex = 'X'.
APPEND lw_tab TO lt_tab2.
CALL FUNCTION 'CTVB_COMPARE_TABLES'
EXPORTING
table_old = lt_tab1
table_new = lt_tab2
key_length = 20
* IF_SORTED =
IMPORTING
table_del = lt_res
* TABLE_ADD =
* TABLE_MOD =
no_changes = g_nochange.
WRITE: 'the tab1 differs from tab2 in that'.
LOOP AT lt_res INTO lw_tab.
WRITE: / lw_tab-name, lw_tab-sex, lw_tab-tel.
ENDLOOP.
--------------------------------------------
the tab1 differs from tab2 in that
Tom Y