‎2007 Jul 26 10:57 AM
DESCRIBE TABLE: TAB1 LINES L1,
TAB2 LINES L2.
IF L1 <> L2.
TAB_DIFFERENT = 'X'.
ELSE.
TAB_DIFFERENT = SPACE.
LOOP AT TAB1.
READ TABLE TAB2 INDEX SY-TABIX.
IF TAB1 <> TAB2.
TAB_DIFFERENT = 'X'. EXIT.
ENDIF .
ENDLOOP.
ENDIF.
IF TAB_DIFFERENT = SPACE.
" ...
ENDIF.
‎2007 Jul 26 11:01 AM
Use this code:
IF TAB1[] NE TAB2[].
TAB_DIFFERENT = 'X'.
ELSE.
TAB_DIFFERENT = space.
ENDIF.
IF TAB_DIFFERENT = SPACE.
" ...
ENDIF.Please mark points if the solution was useful.
Regards,
Manoj
‎2007 Jul 26 1:12 PM
Find a unique key for itab2, here keyfield, and sort itab2 accordingly
sort itab2 by keyfield
loop at tab1 into wa1.
read table tab2 into wa2
with table key keyfield = wa1-keyfield.
index1 = sy-tabix.
entry not in itab2
if ( sy-subrc ne 0 ).
append wa1 to del_tab.
entry in itab2, update if different
else.
delete tab2 index index1.
if ( wa1-ctext ne wa2-ctext ).
append wa2 to upd_tab.
endif.
endif.
endloop.
in itab2 but not in itab1
ins_tab[] = tab2[].
This is the most general solution and performance is good:
del_tab contains lines which are in itab1 but not in itab2
upd_tab contains lines which are in both itab1 and itab2 but are different
ins_tab contains lines which are not in itab1 but in itab2
There are slightly faster solutions but this is one is fast enough, and much easier
to understand and to test.
Siegfried