2007 Aug 17 10:37 AM
HI guys,
I have to compare 2 internal tables with same structure. Every field excepting first field should be compared.
Old, non unicode code is below.
DATA: a TYPE TABLE OF pc20e WITH HEADER LINE,
b TYPE TABLE OF pc20e WITH HEADER LINE.
IF a+1 = b+1.
WRITE: / 'Hello World'.
ENDIF.
That´s just an example of course. The real code is in a HR user exit, so i can´t deactivate UNICODE Check.
Thanks a lot.
HI guys,
I have to compare 2 internal tables with same structure. Every field excepting first field should be compared.
Old, non unicode code is below.
DATA: a TYPE TABLE OF pc20e WITH HEADER LINE,
b TYPE TABLE OF pc20e WITH HEADER LINE.
IF a+1 = b+1.
WRITE: / 'Hello World'.
ENDIF.
That´s just an example of course. The real code is in a HR user exit, so i can´t deactivate UNICODE Check.
Thanks a lot.
2007 Aug 17 10:44 AM
data: flag(1) type c,
l_index type sy-index.
sort: a,b.
l_index =1.
loop at a from index l_index.
read table b index l_index.
if sy-subrc eq 0.
compare the common fields.
if mismatch.
flag =1.
exit.
endif.
else.
flag =1.
exit.
endif,
l_index =l_index+1.
endloop.
if flag eq 1.
write:............
endif.
2007 Aug 17 10:52 AM
Guess, that code doesn't´t resolve the problem.
I want to compare every row, so sy-index isn´t very helpful.
I want to ignore the first column !!
The problem is, that the first field of table is not character like.
2007 Aug 17 11:00 AM
Hello Alexander
I would copy the two internal tables into two temporay itabs of the same structure and initialize the values in the first itab field:
DATA:
lt_itab_pbo TYPE ...,
lt_itab_pai TYPE ...,
ls_entry LIKE LINE OF lt_itab_pbo.
lt_Itab_pbo = itab1.
lt_Itab_pai = itab2.
CLEAR: ls_entry-field1.
MODIFY lt_Itab_pbo FROM ls_entry
TRANSPORTING field1
WHERE ( field1 IS NOT INITIAL ).
MODIFY lt_Itab_pai FROM ls_entry
TRANSPORTING field1
WHERE ( field1 IS NOT INITIAL ).Next I would use the approach that I have published in:
<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/ComparingTwoInternalTables-AGeneric+Approach">Comparing Two Internal Tables - A Generic Approach</a>
Regards
Uwe